<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="referrer" content="never">
    <title>新闻详情页</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        ul {
            list-style: none;
        }

        .content {
            margin: 50px;
        }

        button{
            margin-top: 20px;
            margin-left: 100px;
            padding: 12px 40px;
            font-size: 16px;
            letter-spacing: .1rem;
            background-color: #fff;
            border-radius: 3px;
            border: 1px solid #999;
        }
    </style>
</head>
<body>
    <div class="content">
        <h2>军事</h2>
        <p>content</p>
        <button onclick="history.back()">返回</button>
    </div>

    <script type="text/javascript">
        var hEle = document.querySelector("h2");
        var pEle = document.querySelector("p");
        // ?type=军事
        // ?type=xxx&content=xx&name=value ==> 去掉? 以&分割为数组，在以=分割出对象的键值对
        var search = decodeURI(location.search).slice(1);
        var arr = search.split("&");
        var obj = {};
        for(var i = 0; i < arr.length; i ++){
            var arr2 = arr[i].split("=");
            obj[arr2[0]] = arr2[1];
        }
        console.log(obj);
        hEle.innerText = obj.type;
        pEle.innerText = obj.content;
    </script>
</body>
</html>